package main

import (
	"net"
	"fmt"
	"os"
)
func main() {
	destname:="/home/xiaonu/Desktop/aa2.pdf"
	file1,_:=os.OpenFile(destname,os.O_RDWR|os.O_CREATE,os.ModePerm)
	tcpaddr, _ := net.ResolveTCPAddr("tcp", "10.0.154.209:5555")
	tcpconn, _ := net.DialTCP("tcp", nil, tcpaddr)
	bs := make([]byte, 512)
	for {
		n, _ := tcpconn.Read(bs)
		if n==0 {
			fmt.Println("读完了")
			file1.Close()
			break
		}
		fmt.Println(bs[:n])
		file1.Write(bs[:n])
	}
	tcpconn.Close()
}
